home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / oberonv4 / oberon-src / system / display.mod (.txt) < prev    next >
Encoding:
Oberon Text  |  1996-02-14  |  15.2 KB  |  312 lines

  1. Syntax10.Scn.Fnt
  2. ParcElems
  3. Alloc
  4. Syntax24b.Scn.Fnt
  5. StampElems
  6. Alloc
  7. 14 Feb 96
  8. Syntax10b.Scn.Fnt
  9. Syntax10i.Scn.Fnt
  10. (* AMIGA *)
  11. MODULE Display; (* shml/cn 
  12.     IMPORT SYSTEM,Amiga,G:=AmigaGraphics,I:=AmigaIntuition, Pictures;
  13.     CONST
  14.         black* = Pictures.black; white* = Pictures.white;
  15.         replace* = Pictures.replace; (* The new graphical object completely replaces whatever was before in the destination area. *)
  16.         paint* = Pictures.paint; (* The new graphical object is added to whatever was before in the dertination area. *)
  17.         invert* = Pictures.invert; (* The new graphical object inverts whatever was before in the dertination area. The color specifies, which planes are affected (inverted) and which aren't *)
  18.     TYPE
  19.         Type Frame is declared in this module, but not used, except for defining the clipping areas in
  20.         the ...C procedures. It's module Viewer, which actually uses the dsc, next and handle fields.
  21.         So why aren't they part of ViewerDesc?
  22.         X,Y,W and H define the bounding box of a frame.
  23.         Frame* = Pictures.Frame;
  24.         FrameMsg* = Pictures.FrameMsg;
  25.         Handler* = Pictures.Handler;
  26.         FrameDesc* = Pictures.FrameDesc;
  27.         Pattern* = Pictures.Pattern;
  28.         Font* = POINTER TO Bytes;    (*Amiga.Font*)
  29.         Bytes* = RECORD END;
  30.     TYPE
  31.         Location=RECORD offset,width:INTEGER END;
  32.         LocationArray=ARRAY 256 OF Location;
  33.         LocationPtr=POINTER TO LocationArray;
  34.         SpaceArray=ARRAY 256 OF INTEGER;
  35.         SpacePtr=POINTER TO SpaceArray;
  36.         KernArray=ARRAY 256 OF INTEGER;
  37.         KernPtr=POINTER TO KernArray;
  38.         RastPortPtr=POINTER TO G.RastPort;
  39.         ScreenPtr=POINTER TO I.Screen;
  40.         TextFontPtr=POINTER TO G.TextFont;
  41.         WindowPtr=POINTER TO I.Window;
  42.         Unit*: LONGINT; (*RasterUnit = Unit/36000 mm*)
  43.         Left*, ColLeft*, Bottom*, Width*, Height*: INTEGER;
  44.         arrow*, star*, hook*, cross*, downArrow*: Pattern;
  45.         grey0*, grey1*, grey2*, ticks*: Pattern;
  46.         screen-:Pictures.Picture;
  47.         nofCols: INTEGER;
  48.     PROCEDURE NewPattern*(VAR image: ARRAY OF SET; w, h: INTEGER): Pattern;
  49.     (* Allocates a new pattern with width w and height h. The i-th pattern line from bottom (increasing y-value)
  50.         corresponds to the image entries (i+1)*lineLen .. (i+2)*lineLen-1, where lineLen = (w+31) DIV 32.
  51.         The set elements desribe the pixels from left to right (increasing x-value). *)
  52.     BEGIN
  53.         RETURN Pictures.NewPattern(image,w,h)
  54.     END NewPattern;
  55.     (* Get the Address of Video-RAM, not possible at the AMIGA *)
  56.     PROCEDURE Map*(X, Y: INTEGER): LONGINT;
  57.     BEGIN
  58.         RETURN 0
  59.     END Map;
  60.     (* Activate DIsplay, only one Display realized at the moment *)
  61.     PROCEDURE SetMode*(X: INTEGER; s: SET);
  62.     BEGIN
  63.     END SetMode;
  64.     PROCEDURE SetColor*(col, red, green, blue: INTEGER); (*col < 0: overlay color not supported on the Amiga*)
  65.         Set the RGB values for a color.
  66.         scr:ScreenPtr;
  67.         win: WindowPtr;
  68.     BEGIN
  69.         win := SYSTEM.VAL(WindowPtr, Amiga.window);
  70.         scr := SYSTEM.VAL(ScreenPtr, win.wScreen);
  71.         IF G.gfxVersion<39 THEN
  72.             G.SetRGB4(
  73.                 SYSTEM.VAL(G.ViewPortPtr,SYSTEM.ADR(scr.viewPort)),col MOD nofCols,red DIV 16,green DIV 16,blue DIV 16
  74.         ELSE
  75.             G.SetRGB32(
  76.                 SYSTEM.VAL(G.ViewPortPtr,SYSTEM.ADR(scr.viewPort)),col MOD nofCols,
  77.                 SYSTEM.LSH(LONG(red),24),SYSTEM.LSH(LONG(green),24),SYSTEM.LSH(LONG(blue),24)
  78.         END
  79.     END SetColor;
  80.     PROCEDURE GetColor*(col: INTEGER; VAR red, green, blue: INTEGER);
  81.         Return the RGB values for a color.
  82.         long:LONGINT;
  83.         rgbTable:RECORD r,g,b:LONGINT END;
  84.         scr:ScreenPtr;
  85.         win: WindowPtr;
  86.     BEGIN
  87.         win := SYSTEM.VAL(WindowPtr, Amiga.window);
  88.         scr:=SYSTEM.VAL(ScreenPtr, win.wScreen);
  89.         IF G.gfxVersion<39 THEN
  90.             long:=G.GetRGB4(scr.viewPort.colorMap,col MOD nofCols);
  91.             red:=SHORT(long DIV 256 MOD 16)*17;
  92.             green:=SHORT(long DIV 16 MOD 16)*17;
  93.             blue:=SHORT(long MOD 16)*17
  94.         ELSE
  95.             G.GetRGB32(scr.viewPort.colorMap,col MOD nofCols,1,rgbTable);
  96.             red:=SHORT(SYSTEM.LSH(rgbTable.r,-24));
  97.             green:=SHORT(SYSTEM.LSH(rgbTable.g,-24));
  98.             blue:=SHORT(SYSTEM.LSH(rgbTable.b,-24))
  99.         END
  100.     END GetColor;
  101.     PROCEDURE GetChar*(f: Font; ch: CHAR; VAR dx, x, y, w, h: INTEGER; VAR p: Pattern);
  102.         (*get raster data of character ch*)
  103.     VAR charInfo: Amiga.CharInfo; raster: Amiga.Font;
  104.     BEGIN
  105.         raster := SYSTEM.VAL(Amiga.Font, f); charInfo := raster.info[ORD(ch)];
  106.         dx := charInfo.dx; x := charInfo.x; y := charInfo.y; w := charInfo.w; h := charInfo.h;
  107.         p := SYSTEM.ADR(raster.info[ORD(ch)])
  108.     END GetChar;
  109.     (*raster operations*)
  110.     PROCEDURE CopyBlock*(SX, SY, W, H, DX, DY, mode: INTEGER);
  111.         Copy a rectangular area within the display to another place. This procedure assumes, that any single
  112.         area does not cross the boundary between primary and secondary screen.
  113.     BEGIN
  114.         Pictures.CopyBlock(screen,screen,SX, SY, W, H, DX, DY, mode)
  115.     END CopyBlock;
  116.     PROCEDURE CopyBlockC*(f: Frame; SX, SY, W, H, DX, DY, mode: INTEGER);
  117.         As CopyBlock, but the destination area is clipped against the Frame boundary.
  118.     BEGIN
  119.         Pictures.CopyBlockC(screen,screen,f, SX, SY, W, H, DX, DY, mode)
  120.     END CopyBlockC;
  121.     PROCEDURE CopyPattern*(col: INTEGER; pat: Pattern; X, Y, mode: INTEGER);
  122.         Copy a pattern to the specified location.
  123.     BEGIN
  124.         Pictures.CopyPattern(screen, col, pat, X, Y, mode)
  125.     END CopyPattern;
  126.     PROCEDURE CopyPatternC*(f: Frame; col: INTEGER; pat: Pattern; X, Y, mode: INTEGER);
  127.         As CopyPattern, but clips the pattern against the frame boundary.
  128.     BEGIN
  129.         Pictures.CopyPatternC(screen, f, col, pat, X, Y, mode)
  130.     END CopyPatternC;
  131.     PROCEDURE ReplPattern*(col: INTEGER; pat: Pattern; X, Y, W, H, mode: INTEGER);
  132.         Fill the specified area with the pattern.
  133.     BEGIN
  134.         Pictures.ReplPattern(screen,col,pat,X,Y,W,H,mode)
  135.     END ReplPattern;
  136.     PROCEDURE ReplPatternC*(f: Frame; col: INTEGER; pat: Pattern; X, Y, W, H, X0, Y0, mode: INTEGER);
  137.         (* Replicates a pattern pat within the block (X, Y, W, H), clipped against F. The pattern origin is X0, Y0; i.e. for each
  138.             completely visible occurrence of the pattern pat the following holds: ((x - X0) MOD w = 0) & ((y-Y0) MOD h = 0)
  139.             where (x, y) denotes the left and bottom corner, and (w, h) the size of the pattern. *)
  140.     BEGIN
  141.         Pictures.ReplPatternC(screen,f,col,pat,X,Y,W,H,X0,Y0,mode)
  142.     END ReplPatternC;
  143.     PROCEDURE ReplConst*(col: INTEGER; X, Y, W, H, mode: INTEGER);
  144.         Generate a rectangle with the specified color and paint mode.
  145.     BEGIN
  146.         Pictures.ReplConst(screen,col,X,Y,W,H,mode)
  147.     END ReplConst;
  148.     PROCEDURE ReplConstC*(f: Frame; col: INTEGER; X, Y, W, H, mode: INTEGER);
  149.         As ReplConst, but the rectangle is clipped against the frame boundary.
  150.     BEGIN
  151.         Pictures.ReplConstC(screen,f,col,X,Y,W,H,mode)
  152.     END ReplConstC;
  153.     PROCEDURE Dot*(col: INTEGER; X, Y, mode: INTEGER);
  154.         Change a single pixel.
  155.     BEGIN
  156.         Pictures.Dot(screen,col,X,Y,mode)
  157.     END Dot;
  158.     PROCEDURE DotC*(f: Frame; col: INTEGER; X, Y, mode: INTEGER);
  159.          As Dot, but the the pixel is only written, if contained within the frame boundary.
  160.     BEGIN
  161.         Pictures.DotC(screen,f,col,X,Y,mode)
  162.     END DotC;
  163.     PROCEDURE CreatePatterns;
  164.         Create the images for the exported patterns.
  165.         VAR image: ARRAY 17 OF SET;
  166.     BEGIN
  167.         image[1] := {13};
  168.         image[2] := {12..14};
  169.         image[3] := {11..13};
  170.         image[4] := {10..12};
  171.         image[5] := {9..11};
  172.         image[6] := {8..10};
  173.         image[7] := {7..9};
  174.         image[8] := {0, 6..8};
  175.         image[9] := {0, 1, 5..7};
  176.         image[10] := {0..2, 4..6};
  177.         image[11] := {0..5};
  178.         image[12] := {0..4};
  179.         image[13] := {0..5};
  180.         image[14] := {0..6};
  181.         image[15] := {0..7};
  182.         arrow := NewPattern(image, 15, 15);
  183.         image[1] := {0, 10};
  184.         image[2] := {1, 9};
  185.         image[3] := {2, 8};
  186.         image[4] := {3, 7};
  187.         image[5] := {4, 6};
  188.         image[6] := {};
  189.         image[7] := {4, 6};
  190.         image[8] := {3, 7};
  191.         image[9] := {2, 8};
  192.         image[10] := {1, 9};
  193.         image[11] := {0, 10};
  194.         cross := NewPattern(image,11,11);
  195.         image[1] := {6};
  196.         image[2] := {5..7};
  197.         image[3] := {4..8};
  198.         image[4] := {3..9};
  199.         image[5] := {2..10};
  200.         image[6] := {5..7};
  201.         image[7] := {5..7};
  202.         image[8] := {5..7};
  203.         image[9] := {5..7};
  204.         image[10] := {5..7};
  205.         image[11] := {5..7};
  206.         image[12] := {5..7};
  207.         image[13] := {5..7};
  208.         image[14] := {5..7};
  209.         image[15] := {};
  210.         downArrow := NewPattern(image,15,15);
  211.         image[1] := {0, 4, 8, 12};
  212.         image[2] := {};
  213.         image[3] := {2, 6, 10, 14};
  214.         image[4] := {};
  215.         image[5] := {0, 4, 8, 12};
  216.         image[6] := {};
  217.         image[7] := {2, 6, 10, 14};
  218.         image[8] := {};
  219.         image[9] := {0, 4, 8, 12};
  220.         image[10] := {};
  221.         image[11] := {2, 6, 10, 14};
  222.         image[12] := {};
  223.         image[13] := {0, 4, 8, 12};
  224.         image[14] := {};
  225.         image[15] := {2, 6, 10, 14};
  226.         image[16] := {};
  227.         grey0 := NewPattern(image,16,16);
  228.         image[1] := {0, 2, 4, 6, 8, 10, 12, 14};
  229.         image[2] := {1, 3, 5, 7, 9, 11, 13, 15};
  230.         image[3] := {0, 2, 4, 6, 8, 10, 12, 14};
  231.         image[4] := {1, 3, 5, 7, 9, 11, 13, 15};
  232.         image[5] := {0, 2, 4, 6, 8, 10, 12, 14};
  233.         image[6] := {1, 3, 5, 7, 9, 11, 13, 15};
  234.         image[7] := {0, 2, 4, 6, 8, 10, 12, 14};
  235.         image[8] := {1, 3, 5, 7, 9, 11, 13, 15};
  236.         image[9] := {0, 2, 4, 6, 8, 10, 12, 14};
  237.         image[10] := {1, 3, 5, 7, 9, 11, 13, 15};
  238.         image[11] := {0, 2, 4, 6, 8, 10, 12, 14};
  239.         image[12] := {1, 3, 5, 7, 9, 11, 13, 15};
  240.         image[13] := {0, 2, 4, 6, 8, 10, 12, 14};
  241.         image[14] := {1, 3, 5, 7, 9, 11, 13, 15};
  242.         image[15] := {0, 2, 4, 6, 8, 10, 12, 14};
  243.         image[16] := {1, 3, 5, 7, 9, 11, 13, 15};
  244.         grey1 := NewPattern(image,16,16);
  245.         image[1] := {0, 1, 4, 5, 8, 9, 12, 13};
  246.         image[2] := {0, 1, 4, 5, 8, 9, 12, 13};
  247.         image[3] := {2, 3, 6, 7, 10, 11, 14, 15};
  248.         image[4] := {2, 3, 6, 7, 10, 11, 14, 15};
  249.         image[5] := {0, 1, 4, 5, 8, 9, 12, 13};
  250.         image[6] := {0, 1, 4, 5, 8, 9, 12, 13};
  251.         image[7] := {2, 3, 6, 7, 10, 11, 14, 15};
  252.         image[8] := {2, 3, 6, 7, 10, 11, 14, 15};
  253.         image[9] := {0, 1, 4, 5, 8, 9, 12, 13};
  254.         image[10] := {0, 1, 4, 5, 8, 9, 12, 13};
  255.         image[11] := {2, 3, 6, 7, 10, 11, 14, 15};
  256.         image[12] := {2, 3, 6, 7, 10, 11, 14, 15};
  257.         image[13] := {0, 1, 4, 5, 8, 9, 12, 13};
  258.         image[14] := {0, 1, 4, 5, 8, 9, 12, 13};
  259.         image[15] := {2, 3, 6, 7, 10, 11, 14, 15};
  260.         image[16] := {2, 3, 6, 7, 10, 11, 14, 15};
  261.         grey2 := NewPattern(image,16,16);
  262.         image[1] := {0..7};
  263.         image[2] := {0..6};
  264.         image[3] := {0..5};
  265.         image[4] := {0..4};
  266.         image[5] := {0..3};
  267.         image[6] := {0..2};
  268.         image[7] := {0..1};
  269.         image[8] := {0};
  270.         hook := NewPattern(image,8,8);
  271.         image[1] := {7};
  272.         image[2] := {7};
  273.         image[3] := {2, 7, 12};
  274.         image[4] := {3, 7, 11};
  275.         image[5] := {4, 7, 10};
  276.         image[6] := {5, 7, 9};
  277.         image[7] := {6..8};
  278.         image[8] := {0..6, 8..14};
  279.         image[9] := {6..8};
  280.         image[10] := {5, 7, 9};
  281.         image[11] := {4, 7, 10};
  282.         image[12] := {3, 7, 11};
  283.         image[13] := {2, 7, 12};
  284.         image[14] := {7};
  285.         image[15] := {7};
  286.         star := NewPattern(image,15,15);
  287.         image[1] := {0};
  288.         image[2] := {};
  289.         image[3] := {};
  290.         image[4] := {};
  291.         image[5] := {};
  292.         image[6] := {};
  293.         image[7] := {};
  294.         image[8] := {};
  295.         image[9] := {};
  296.         image[10] := {};
  297.         image[11] := {};
  298.         image[12] := {};
  299.         image[13] := {};
  300.         image[14] := {};
  301.         image[15] := {};
  302.         image[16] := {};
  303.         ticks := NewPattern(image,16,16)
  304.     END CreatePatterns;
  305. BEGIN
  306.     Left := 0; ColLeft := 0; Bottom := 0;
  307.     Width := Amiga.Width; Height := Amiga.Height; Unit := 14000;
  308.     nofCols:=SHORT(ASH(1, Amiga.Depth));
  309.     CreatePatterns;
  310.     Pictures.WindowToPicture(Amiga.window,screen)
  311. END Display.
  312.